<template>
	<view>
		<scroll-view scroll-y="true" class="content" :enhanced="true" :bounces="false" :show-scrollbar="false">
			<view class="u-content">
				<u-parse :content="context"></u-parse>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		queryOneByApp,
		queryInvestmentProductDetailByApp
	} from "@/api/index.js"

	export default {
		data() {
			return {
				type: "",
				code: "",
				context: ""
			}
		},
		onLoad(opt) {
			console.log('--------------------')
			this.type = opt.type
			if (opt.type == 'banner') {
				uni.setNavigationBarTitle({
					title: "新闻中心"
				})
				this.code = opt.bannerCode
			} else {
				uni.setNavigationBarTitle({
					title: "投资详情"
				})
				this.code = opt.productCode
			}
		},
		async onShow() {
			if (this.type == 'banner') {
				this.queryOneByApp(this.code)
			} else {
				this.queryByDetailByApp(this.code)
			}

		},
		methods: {
			async queryOneByApp(code) {
				await queryOneByApp({
					bannerCode: code
				}).then(res => {
					this.context = res.object.bannerContext
				})
			},

			async queryByDetailByApp(code) {
				await queryInvestmentProductDetailByApp({
					productCode: code
				}).then(res => {
					this.context = res.object.investmentRichText
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		//可视高度，需要在多大的盒子中进行滑动
		height: 100vh;
		width: 100%;
	}

	.u-content {
		padding: 24rpx;
	}
</style>